﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace 树结构菜单.UDataTemplate
{
    public class MyDataTemplate : DataTemplateSelector
    {
        public DataTemplate NormalTemplate { get; set; }
        public DataTemplate ErrorTemplate { get; set; }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            DataItem? dataItem = item as DataItem;
            if(dataItem.Rate < 50)
            {
                return ErrorTemplate;
            }

            return NormalTemplate;
        }
    }
}
